//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.cnhis.drgs.crypt;


import org.springframework.util.DigestUtils;

public class Md5 {


    //盐，用于混交md5
    private static String SALT = "@#%23$kuyacs^54~3b&*&";
    public Md5() {
    }


    /**
     * 生成md5 默认盐
     * @param str
     * @return
     */
    public static String encode(String str) {
        String base = str + "/" + SALT;
        return DigestUtils.md5DigestAsHex(base.getBytes());
    }


    /**
     * 生成md5 自定义盐
     * @param str
     * @return
     */
    public static String encode(String str,String salt) {
        String base = str + "/" + salt;
        String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
        return md5;
    }


    public static String encode16(String str) {
        return encode(str).substring(8, 24);
    }
}

